package com.example.iot.utils;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.iot.R;

public class ToastUtils {
    private Context mycontext;
    public ToastUtils(Context context){
        this.mycontext=context;
    }
   public void showToastTopLong(String content){
       View view= LayoutInflater.from(mycontext).inflate(R.layout.toast_layout,null);
        Toast toast=new Toast(mycontext);
        TextView textView=(TextView)view.findViewById(R.id.tv_toast_text);
        textView.setText(content);
        toast.setView(view);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setGravity(Gravity.TOP,0,20);
        toast.show();
    }
    public void showToastCenterLong(String content){
        View view= LayoutInflater.from(mycontext).inflate(R.layout.toast_layout,null);
        Toast toast=new Toast(mycontext);
        TextView textView=(TextView)view.findViewById(R.id.tv_toast_text);
        textView.setText(content);
        toast.setView(view);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER,0,0);
        toast.show();
    }
    public void showToastBottomLong(String content){
        View view= LayoutInflater.from(mycontext).inflate(R.layout.toast_layout,null);
        Toast toast=new Toast(mycontext);
        TextView textView=(TextView)view.findViewById(R.id.tv_toast_text);
        textView.setText(content);
        toast.setView(view);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM,0,50);
        toast.show();
    }
}
